package ua.net.gm.server.world;

import ua.net.gm.common.entity.EntityDict;
import ua.net.gm.common.entity.EntityId;
import ua.net.gm.common.entity.EntitySupport;
import ua.net.gm.common.entity.EntityType;
import ua.net.gm.common.entity.IEntityDict;
import ua.net.gm.common.entity.IEntityDictFactory;

/**
 *
 * @author syar
 */
public class WorldId extends EntityId
{
    public static final String ID = "world";

    WorldId(EntitySupport entitySupport, EntityType entityType)
    {
        super(entitySupport, 
                entityType != null ? entityType : 
                        entitySupport.createType(ID, new WorldIdDictFactory()));
    }

    public static void init(EntitySupport entitySupport)
    {
        entitySupport.createType(ID, new WorldIdDictFactory());
    }
            
    private static class WorldIdDictFactory implements IEntityDictFactory<WorldId>
    {
        @Override
        public IEntityDict<WorldId> create(final EntitySupport entitySupport, final EntityType entityType)
        {
            return new EntityDict<WorldId>()
            {
                @Override
                protected WorldId createId()
                {
                    return new WorldId(entitySupport, entityType);
                }
            };
        }
    }
}
